<#assign base=request.contextPath />
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<#include "/common/common.ftl">
<@pnotify/>
<@layui/>
<@selfcss/>
</head>
<body>
<div class="form-horizontal layui-form">
    <div class="modal-body row">
        <div class="form-group col-md-3">
            <label for="icon_show" class="control-label img_label">头像</label>
            <div class="site-demo-upload">
                <img id="icon_show" src="${base}/resources/images/tong.jpg">
                <div class="site-demo-upbar">
                    <div class="layui-box layui-upload-button">
                        <form target="layui-upload-iframe" method="get" key="set-mine" enctype="multipart/form-data"
                              action="${base}/resources/test/test.json">
                            <input type="file" name="file" class="layui-upload-file" id="file_icon">
                        </form>
                        <span class="layui-upload-icon"><i class="layui-icon"></i>上传图片</span></div>
                </div>
            </div>
        </div>

        <form method="post" action="${base}/vip/customer" id="add_vip_form" class="layui-form form-group col-md-8">
            <input type="hidden" name="icon" id="icon"/>
            <div class="form-group col-md-6">
                <label for="name" class="col-md-4 control-label">会员姓名</label>
                <div class="col-md-8">
                    <input type="text" name="name" class="form-control" lay-verify="name" value="${customer.name}"
                           id="name"
                           placeholder="会员姓名">
                </div>
            </div>
            <div class="form-group col-md-6">
                <label for="cardNo" class="col-md-4 control-label">会员卡号</label>
                <div class="col-md-8">
                    <input type="text" name="cardNo" class="form-control" lay-verify="cardNo" value="${customer.cardNo}"
                           id="cardNo"
                           placeholder="会员卡号">
                </div>
            </div>
            <div class="form-group col-md-6">
                <label for="phone" class="col-md-4 control-label">电话号码</label>
                <div class="col-md-8">
                    <input type="text" name="phone" class="form-control" lay-verify="phone" value="${customer.phone}"
                           id="phone"
                           placeholder="电话号码">
                </div>
            </div>
            <div class="form-group col-md-6">
                <label for="birthday" class="col-md-4 control-label">生日</label>
                <div class="col-md-8">
                <#--<div class="layui-inline">-->
                <#--<div class="layui-input-inline">-->
                    <input type="text" name="birthday" id="birthday" lay-verify="birthday" autocomplete="off"
                           class="layui-input" onclick="layui.laydate({elem: this})"
                           placeholder="生日" value="${customer.birthday}">
                <#--</div>-->
                <#--</div>-->
                </div>
            </div>

            <div class="form-group col-md-6">
                <label for="idNo" class="col-md-4 control-label">身份证号</label>
                <div class="col-md-8">
                    <input type="text" name="idNo"
                           lay-verify="idNo"
                           class="form-control"
                           value="${customer.idNo}"
                           id="idNo"
                           placeholder="身份证号">
                </div>
            </div>
            <div class="form-group col-md-6">
                <label for="level" class="col-md-4 control-label">会员级别</label>
                <div class="col-md-8">
                    <input type="text" name="level"
                           lay-verify="level"
                           class="form-control"
                           value="${customer.level}"
                           id="level"
                           placeholder="会员级别">
                </div>
            </div>
            <div class="form-group col-md-6">
                <label for="address" class="col-md-4 control-label">住址</label>
                <div class="col-md-8">
                    <input type="text" name="address" class="form-control"
                           lay-verify="address"
                           value="${customer.address}"
                           id="address"
                           placeholder="住址">
                </div>
            </div>
            <div class="form-group col-md-6">
                <label for="validity" class="col-md-4 control-label">有效期</label>
                <div class="col-md-8">
                    <input type="text" name="validity" id="validity" lay-verify="validity" autocomplete="off"
                           class="layui-input"
                           onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"
                           placeholder="有效期"
                           value="${customer.validity}">
                </div>
            </div>
            <div class="form-group col-md-6">
                <label for="startTime" class="col-md-4 control-label">开卡日期</label>
                <div class="col-md-8">
                <#--<div class="layui-inline">-->
                    <input type="text" name="startTime" id="startTime" lay-verify="startTime" autocomplete="off"
                           class="layui-input"
                           onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"
                           placeholder="开卡日期"
                           value="${customer.startTime}">
                <#--</div>-->
                </div>
            </div>
            <div class="form-group col-md-6">
                <label for="endTime" class="col-md-4 control-label">到期日期</label>
                <div class="col-md-8">
                    <input type="text" name="endTime" id="endTime" lay-verify="endTime" autocomplete="off"
                           class="layui-input"
                           onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"
                           placeholder="到期日期"
                           value="${customer.endTime}">
                </div>
            </div>
            <div class="form-group col-md-6">
                <label for="counselorId" class="col-md-4 control-label">会籍顾问</label>
                <div class="col-md-8">
                <#--<input type="text" name="counselorId" class="form-control"-->
                <#--lay-verify="counselorId"-->
                <#--value="${customer.counselorId}"-->
                <#--id="counselorId" placeholder="会籍顾问">-->
                    <select name="counselorId" id="counselorId" lay-verify="counselorId" value="${customer.sex}"
                            placeholder="会籍顾问">
                        <option value="">请选会籍顾问</option>
                    <#--<option value="M">男</option>-->
                    <#--<option value="FM">女</option>-->
                    <#--<option value="OT">其他</option>-->
                    </select>
                </div>
            </div>
            <div class="form-group col-md-6">
                <label for="sex" class="col-md-4 control-label">性别</label>
                <div class="col-md-8">
                <#--<div class="layui-form-item">-->
                <#--<div class="layui-input-inline">-->
                    <select name="sex" id="sex" lay-verify="sex" value="${customer.sex}" placeholder="性别">
                        <option value="">请选择市</option>
                        <option value="M">男</option>
                        <option value="FM">女</option>
                        <option value="OT">其他</option>
                    </select>
                <#--</div>-->
                <#--</div>-->
                </div>
            </div>
        </form>
    </div>
    <div class="modal-footer ">
        <button type="button" class="btn btn-primary" <#--id="sub_add_btn"--> lay-submit="" lay-filter="add">保存</button>
        <button type="button" class="btn btn-default close_btn" data-dismiss="modal">关闭</button>
    </div>
</div>
<@index/>
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form();
        //自定义验证规则
        form.verify({
            name: function (value) {
                if (value == "") {
                    return '请填写会员姓名！';
                }
            },
            startTime: function (value) {
                if (value == "") {
                    return '请选择开卡日期！';
                }
            }, endTime: function (value) {
                if (value == "") {
                    return '请选择到期日期！';
                }
            },
            phone: function (value) {
                if (value == "") {
                    return '请填写客户手机号！';
                }
                if (value.length > 11) {
                    return '请正确填写客户11位手机号！';
                }
            }, idNo: function (value) {
                if (value == "") {
                    return '请填写客户身份证号！';
                }
                if (value.length > 18) {
                    return '请正确填写客户18位身份证号！';
                }
            }, cardNo: function (value) {
                if (value == "") {
                    return '请填写客户会员卡号！';
                }
            }, counselorId: function (value) {
                if (value == "") {
                    return '请选择会籍顾问！';
                }
            }, sex: function (value) {
                if (value == "") {
                    return '请选择性别！';
                }
            }
            // , pass: [/(.+){6,12}$/, '密码必须6到12位']
            // , content: function (value) {
            //     layedit.sync(editIndex);
            // }
        });
        //监听提交
        form.on('submit(add)', function (data) {
            $.post($('#add_vip_form').attr('action'), $('#add_vip_form').serialize(), function (data) {
                top.window.location.href = base + "/vip/customer?sort=start_time,desc";
            }, 'html');
            return false;
        });
    });

</script>
</body>
</html>
